package com.three.controller;

import com.three.aop.LogAnotation;
import com.three.entity.Inlibrary;
import com.three.service.IntLibraryService;
import com.three.vo.BranchVo;
import com.three.vo.R;
import com.three.vo.intLibraryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/intlibrary")
public class IntLibraryController {
    @Autowired
    private IntLibraryService intLibraryService;
//点击新增入库展示所有
    @PostMapping("/getAllInLib")
    public R list(Integer pageNum, Integer pageSize, @RequestBody BranchVo branchVo){
        return intLibraryService.list(pageNum,pageSize,branchVo);
    }

    //添加入库
    @PostMapping("/addIntLib")
    @LogAnotation(value = "添加入库")
    public R addIntLibrary(@RequestBody List<intLibraryVO> inlibrary){
        return intLibraryService.addIntLibrary(inlibrary);
    }


    //申请通过
    @PostMapping("/approved")
    @LogAnotation(value = "申请通过")
    public R updateStateYes(Integer id){
        return intLibraryService.approved(id);

    }

    //申请驳回
    @PostMapping("/reject")
    @LogAnotation(value = "申请驳回")
    public R updateStateNo(Integer id,String remark){
        return intLibraryService.rejected(id,remark);
    }

    //获取店铺id
    @GetMapping("/getbranchid")
    public R selectByBranchid(){
        return intLibraryService.getUserBranchId();
    }
    //根据id获取店铺信息
    @GetMapping("/getBranchByid")
    public R getBranchByid(Integer id){
        return intLibraryService.getBranchByid(id);
    }

}
